package com.elong.businesstravel.protocol.ticket;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.android.support.jhf.debug.DebugLog;
import com.elong.businesstravel.entitys.TrainTicket;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class StartEndInfosResponse extends BaseELongJsonHttpResponse {

	protected List<TrainTicket> trainTickets = new ArrayList<TrainTicket>();
	
	@Override
	public void onSuccess(int statusCode, Header[] headers,
			org.json.JSONObject mainJsonObject) throws Throwable {

		JSONObject jsonObject = JSONObject.parseObject(mainJsonObject
				.toString());
		JSONArray jsonArray = jsonObject.getJSONArray("tickets");
		if (null != jsonArray) {
			for (int i = 0; i < jsonArray.size(); i++) {
				TrainTicket trainTicket = JSON.toJavaObject(jsonArray.getJSONObject(i), TrainTicket.class);
				trainTickets.add(trainTicket);
			}
		}
	}

}
